$(document).ready(function(){
//调用接口
	
	/*	$.get("../../back/menu/getMenus",function (obj){
	        console.log(obj);
	    })*/
	$(function(){
		
		$.when(getHtml()).then(getMenus);
	})
	function getHtml(){
		return	$.ajax({
			type:"get",
			url:"../../static/background/menu/order_managrzrajax.ftl",
			async:true,
			dataType: "text",
			success: function(obj) {
				$(".borzr").append(obj);
			}
		}).promise();
	}

	function getMenus(){
		return $.get("../../back/menu/getMenus",function (obj){
			 console.log(obj);
			 $("#menulist").html("");
			 var innerhtml = "";
			for(var i=0;i<obj.data.length;i++){
				innerhtml += "<ul class='menu_detail'>" +
	                      "<li class='menu_index'>" + (i+1) + "</li>" +
	                      "<li class='menu_name'>"+obj.data[i].name+"</li>" +
	                      "<li class='menu_sort'>"+obj.data[i].index+"</li>" +
	                      "<li class='menu_createTime'>"+obj.data[i].createDate+"</li>" ;
						if(obj.data[i].state==0){
							innerhtml += "<li class='menu_state'>正常使用</li>";
						}else{
							innerhtml += "<li class='menu_state'>已停用</li>";
						}
	                      innerhtml += "<li class='menu_operation'>" +
	                      "<div class='menu_change'>"+"修改"+"</div>" +
	                      "<div class='menu_delete' onclick='deleteMenu(this)'>"+"删除"+"</div>" +
	                      "<input type='hidden' value='"+obj.data[i].id+"'/>"+
	                      "</li>" +"</ul>";
			 }
			$("#menulist").append(innerhtml);
			 
        }).promise();
	}
})